package singleton;

/**
 * @ClassName Singletion
 * @Description 单例模式优雅写法，不用考虑volatile和双锁
 * @Author zhangx
 * @Date 2021/5/27 8:52
 **/
public class Singleton {

    /**
     * 内部静态类
     */
    private static class SingletonHolder{

        public static Singleton instance = new Singleton();
    }

    /**
     * 构造函数私有
     */
    private Singleton(){

    }

    public static Singleton getInstance(){
        return SingletonHolder.instance;
    }
}
